package cn.xaut.贪心算法;

public class demo392 {

    public boolean isSubsequence(String s, String t) {
        
        if (s.equals(""))
            return true;

        char[] ss = s.toCharArray();
        char[] ts = t.toCharArray();

        int si = 0, ti = 0;
        while (si < ss.length && ti < ts.length) {

            if (ss[si] == ts[ti]) {
                si ++;
                ti ++;
            } else
                ti ++;
        }

        return si == ss.length;
    }

    public static void main(String[] args) {

        System.out.println(new demo392().isSubsequence("abc", "ahbgdc"));//true
        System.out.println(new demo392().isSubsequence("axc", "ahbgdc"));//false
    }
}
